{% extends "base.html" %}
{% set row_limit = 10 %}

{% block title %}Statistics{% endblock %}

{% block body %}
<div class='row' id='date_stats'>
  <div class='col-md-3'>
    <ul class='nav nav-pills nav-stacked'>
      {% for release in releases %}
        <li>
        <a href="#{{ release.release }}">
          {{ release.release }}</a>
        </li>
      {% endfor %}
    </ul>
  </div>

  <div class='col-md-9'>
    <h3>Summary</h3>
    <p>
      <dl class='dl-horizontal'>
        <dt>Since date:</dt>
        <dd> {{ since }} </dd>
        <dt>To date:</dt>
        <dd> {{ to }} </dd>
        <dt>Reports:</dt>
        {% if total %}
          <dd>{{ total|readable_int }}</dd>
        {% else %}
          <dd>No reports</dd>
        {% endif %}
      </dl>
    </p>

    {% for release in releases %}
      <hr />
      <div class='row' id='{{ release.release }}'>
        <div class='col-md-4'>
          <h3>{{ release.release }}</h3>
          <dl class='dl-horizontal'>
            <dt>Reports:</dt>
            <dd>{{ release.sum|readable_int }} ({{ release.percentage }}%)</dd>
            <dt>Components:</dt>
            <dd>{{ release.comps|length|readable_int }}</dd>
          </dl>
        </div>
        <div class='col-md-5'>
          <table class='comps table table-striped table-bordered'>
            <thead>
              <tr>
                <th>Component</th>
                <th>Count</th>
                <th>Share</th>
              </tr>
            </thead>
            {% for comp, count, percentage in release.comps %}
              {% if loop.index > row_limit and release.comps|length > row_limit + 1 %}
                <tr class="package hide">
              {% else %}
                <tr class="package">
              {% endif %}
                <td>{{ comp }}</td>
                <td class="cell-count">{{ count|readable_int }}</td>
                <td>
                <div class="progress progress-info progress-striped">
                  <div class="progress-bar" role="progressbar"
                    style="width: {{ percentage }}%">
                  </div>
                </div>
                </td>
              </tr>
              {% if loop.index == row_limit and release.comps|length > row_limit + 1 %}
                <tr>
                  <td colspan="3" class="text-center">
                    <a href="#" class="btn-more">Show more… ({{ release.comps|length - row_limit }})</a>
                  </td>
                </tr>
              {% endif %}
            {% endfor %}
          </table>
        </div>
      </div>
    {% endfor %}
  </div>
</div>
{% endblock %}
